<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="bolao" />
    <g:set var="entityName" value="${message(code: 'role.label', default: 'Role')}" />
    <title><g:message code="default.edit.label" args="[entityName]" /></title>
  </head>
  <body>
    <div class="body">
      <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
      </g:if>
      <g:hasErrors bean="${role}">
        <div class="errors">
          <g:renderErrors bean="${role}" as="list" />
        </div>
      </g:hasErrors>
      <g:form>
        <g:hiddenField name="id" value="${role?.id}" />
        <g:hiddenField name="version" value="${role?.version}" />
        <div class="dialog">
        <fieldset>
          <legend><g:message code="default.edit.label" args="[entityName]" /></legend>
          <table>
            <tbody>
              <tr class="prop">
                <td valign="top" class="name"><label for="code"><g:message code="role.code.label"/>:</label></td>
                <td valign="top" class="value ${hasErrors(bean:role,field:'code','errors')}">
                  <input type="text" id="code" name="code" value="${role.code?.encodeAsHTML()}" disabled/>
                </td>
              </tr>
              <tr class="prop">
                <td valign="top" class="name"><label for="description"><g:message code="role.description.label"/>:</label></td>
                <td valign="top" class="value ${hasErrors(bean:role,field:'description','errors')}">
                  <input type="text" id="description" name="description" value="${role.description?.encodeAsHTML()}"/>
                </td>
              </tr>
            <g:if test="${!role?.users.isEmpty()}">
            <tr>
              <td colspan="2"><g:message code="role.users.label"/>:</td>
            </tr>
            <tr>
              <td colspan="2">
                <div class="list">
                  <table class="table">
                    <thead>
                      <tr>
                    <g:sortableColumn property="username" titleKey="user.username.label" />
                    <g:sortableColumn property="firstname" titleKey="user.firstname.label" />
                    </tr>
                    </thead>
                    <tbody>
                    <g:each in="${role?.users}" status="i" var="user">
                      <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        <td><g:link controller="user" action="show" id="${user?.id}">${user?.username?.encodeAsHTML()}</g:link></td>
                        <td>${user?.firstname?.encodeAsHTML()} ${user?.surname?.encodeAsHTML()}</td>
                      </tr>
                    </g:each>
                    </tbody>
                  </table>
                </div>
              </td>
            </tr>
            </g:if>
            </tbody>
          </table>
          </fieldset>
        </div>
        <div class="buttons">
          <span class="button"><g:actionSubmit action="update" class="save" value="${message(code:'global.update')}" action="update" /></span>
        </div>
      </g:form>
    </div>
  </body>
</html>